//
//  VKSettingCell.m
//  V-Learn
//
//  Created by liubo on 2019/1/11.
//  Copyright © 2019 yxk. All rights reserved.
//

#import "VKSettingCell.h"

@implementation VKSettingCell{
    UIImageView *_imageV;
    UILabel *_contentLabel;
}

+ (instancetype)cellWithTableView:(UITableView *)tableView{
    VKSettingCell *cell = [tableView dequeueReusableCellWithIdentifier:@"VKSettingCell"];
    if (cell == nil) {
        cell = [[VKSettingCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"VKSettingCell"];
    }
    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    return cell;
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // 点击cell的时候不要变色
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor whiteColor];
        
        // 布局子控件
        [self autoLayout];
    }
    return self;
}

-(void)setModel:(VKSettingModel *)model{
    _model = model;
    _contentLabel.text = model.content;
    if (model.row == 0) {
        _rightLabel.text = @"";
    }else if (model.row == 1){
        _rightLabel.text = @"V2.0";
        _rightLabel.textColor = [UIColor cz_colorWithRed:153 green:153 blue:153];
    }else if (model.row == 2){
        _rightLabel.text = model.rightStr;
        _rightLabel.textColor = [UIColor cz_colorWithRed:253 green:79 blue:83];
    }
}

- (void)autoLayout{
    

    UILabel *contentLabel = [[UILabel alloc]init];
    _contentLabel = contentLabel;
    [self.contentView addSubview:contentLabel];
    contentLabel.textColor = [UIColor cz_colorWithRed:62 green:62 blue:62];
    contentLabel.font = [UIFont systemFontOfSize:17];
    [contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self).offset(15);
        make.centerY.mas_equalTo(self.contentView);
    }];
    
    UIImageView *arrowImageV = [[UIImageView alloc]init];
    arrowImageV.image = [UIImage imageNamed:@"left"];
    [self.contentView addSubview:arrowImageV];
    [arrowImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        //        make.height.width.mas_equalTo(30);
        make.right.mas_equalTo(-15);
        make.centerY.mas_equalTo(self.contentView);
    }];
    
    UIView *lineView = [[UIView alloc]init];
    [self.contentView addSubview:lineView];
    lineView.backgroundColor = [UIColor cz_colorWithRed:244 green:244 blue:244];
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(@0);
        make.height.equalTo(@1);
        make.bottom.mas_equalTo(self.contentView);
    }];
    
    UILabel *rightLabel = [[UILabel alloc]init];
    _rightLabel = rightLabel;
    [self.contentView addSubview:rightLabel];
//    rightLabel.text = @"124M";
    rightLabel.textColor = [UIColor cz_colorWithRed:62 green:62 blue:62];
    rightLabel.font = [UIFont systemFontOfSize:16];
    [rightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(arrowImageV.mas_left).offset(-10);
        make.centerY.mas_equalTo(self.contentView);
    }];
    
}


@end
